<template>
  <div id="app">
    <div><h3>神州数码精准测试工具演示程序</h3></div>
    <el-row>
      <el-col :span="6">
        <el-form ref="form"  label-position="left" :model="form" label-width="150px">
          <el-form-item label="活动名称：">
            <el-input v-model="form.name" style="width:300px;"></el-input>
          </el-form-item>
          <el-form-item label="被测系统地址：">
            <el-input v-model="form.url" style="width:300px;"></el-input>
          </el-form-item>
          <el-form-item label="活动区域：">
            <el-select v-model="form.region" placeholder="请选择活动区域" style="width:300px;">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
        
          <el-form-item label="是否保存：" style="width:300px;">
            <el-switch v-model="form.isSave"></el-switch>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">保存</el-button>
            <el-button>取消</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import axios from "axios"
export default {
  name: 'App',
  data () {
    return {
      form: {
          name: '神州数码精准测试工具演示程序',
          url:'http://localhost:8187/helloa0',
          region: '',
          isSave: true,
        }
    }
  },
  methods: {
    onSubmit() {
      console.log('submit!');
      try {
        axios({
            url:this.form.url,
            method:'get', 
            params:{ 
              isSave:this.form.isSave,
            }
        }).then((response) => {
          this.$message({
            message: "返回数据:"+response.data,
            type: 'success'
          });
        })
        .catch((error) => {
          this.$message({
            message: "服务器无法正常访问",
            type: 'error'
          });
            console.log(error);
        });
      } catch (error) {
        console.error("请求失败:", error);
      }
    }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  margin-top: 10px;
}
</style>
